﻿using UnityEngine;
using System.Collections;

public class Hud : MonoBehaviour 
{
	public GUIStyle custonText;
	public float X;
	public float Y;

	public GameObject player;

	public float health;
	float originalhealth;

	public int life;
	
	// Use this for initialization
	void Start () 
	{
		originalhealth = health;
	}
	
	// Update is called once per frame
	void Update () 
	{
		if(health > originalhealth)
		{
			health = originalhealth;
		}
		if(health == 0)
		{	
			player.transform.position = player.GetComponent<PlayerMoviment>().posOrigin;
			health = originalhealth;
			life -= 1;
		}
	}
	void OnGUI ()
	{
		GUI.Box (new Rect (Screen.width/X,Screen.height/Y,health,originalhealth/5), "Health");
		GUI.Label (new Rect (Screen.width/X,Screen.height/Y-20,originalhealth,originalhealth/5), "Life X " + life);
	}
}
